﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wwtfly.BBS.BackModels.Models.Users;
using Wwtfly.Utility;
using Wwtfly.BBS.BackModels.Models.Right;
using Wwtfly.BBS.BackBLL.Right;
using Wwtfly.BBS.BackBLL.Users;
using System.Collections;
using Wwtfly.BBS.BackModels.Models.Users.Right;

namespace Wwtfly.BBS.ForeApplication.WebForm.Shared
{
    public partial class Head : System.Web.UI.UserControl
    {
        protected static UsersModel usermodel = null;
        protected static string  userRole ="";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session[LoginUserUtil.LOGIN_USER] != null)
                {
                    usermodel = (UsersModel)Session[LoginUserUtil.LOGIN_USER];
                    IList<UARoleInfoModel> userRoleList = UsersBLL.GetUARoleInfoList(usermodel.Id);
                    int roleid = 6;
                    string RoleCodes = "";
                    foreach (UARoleInfoModel role in userRoleList)
                    {

                        if (role.RoleID < roleid)
                        {
                            roleid = role.RoleID;
                            RoleCodes = role.RoleCode;
                        }

                    }
                    userRole = ReRoleName(RoleCodes,usermodel.UserName);

                }
               
            }
        }
        public static string ReRoleName(string RoleCodes,string username)
        {
            string rolename = "";
            switch (RoleCodes)
            {
                case "General":
                    rolename = "普通用户：<a href=\"UserAcount.aspx\" >" + username + "</a>&nbsp;&nbsp;<a href=\"UserAcount.aspx\" >[个人资料]</a>";
                    break;
                case "ZhuangJia":
                    rolename = "专家用户：<a href=\"UserAcount.aspx\" >" + username + "</a>&nbsp;&nbsp;<a href=\"UserAcount.aspx\" >[个人资料]</a>";
                    break;
                case "FOREBBS_SUPERMAN":
                    rolename = "前台管理员：<a href=\"UserAcount.aspx\" >" + username + "</a>&nbsp;&nbsp;<a href=\"UserAcount.aspx\" >[个人资料]</a>";
                    break;
                case "BACKBBS_SUPERMAN":
                    rolename = "后台管理员：<a href=\"../BackHome/login.html\" >" + username + "</a>&nbsp;&nbsp;<a href=\"UserAcount.aspx\" >[个人资料]</a>";
                    break;
                default:
                    rolename = "普通用户：<a href=\"UserAcount.aspx\" >" + username + "</a>&nbsp;&nbsp;<a href=\"UserAcount.aspx\" >[个人资料]</a>";
                    break;
            }
            return rolename;
        }

    }
}